package com.mzy.interview

/**
 * @Author: mizy3
 * @Date: 2024/08/25/下午12:26
 * @Description:
 */
class 环形链表 {

    fun hasCycle(head: ListNode?): Boolean {
        var fast  = head
        var slow = head
        while (fast?.next != null){
            slow = slow!!.next
            fast = fast.next!!.next
            if(slow == fast) return true
        }
        return false
    }
}